﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NetJsWire.Widgets.Ui.Window;

namespace UIProject
{
    public partial class Form1 : Window
    {
        private List<DataItem> _data = new List<DataItem> { new DataItem { Id = 0, Name = "First" }, new DataItem { Id = 1, Name = "Second" } };
        public Form1()
        {
            InitializeComponent();

            button1.On( "click", "function(b){b.ownerCt.close();}" );
            table1.DataSource = _data;
            comboBox1.DataSource = _data;
        }

        private void table1_CellValueChanged( object sender, DataGridViewCellEventArgs e )
        {
            if ( e.RowIndex >= 0 && e.ColumnIndex >= 0 )
            {
                NetJsWire.Widgets.Ui.MessageBox.MessageBox.Alert( "System",
                                                                  "Changed the value on cell: [" + e.RowIndex + ", " +
                                                                  e.ColumnIndex + "] to: " + table1.Rows[ e.RowIndex ].Cells[ e.ColumnIndex ].Value );
            }
        }
    }

    /// <summary>
    /// Helper data class
    /// </summary>
    public class DataItem
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
